home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Programmation / Gooey1.3.1 / C Templates / Events.c < prev    next >
Text File  |  1995-01-31  |  8KB  |  302 lines

  1. $$Message User Events, u:events$Prototype.name$.h
  2. $$File u:events$Prototype.name$.h
  3. /*  $CopyRight$ */
  4. /*  events$Prototype.name$                                Additional event handler routines
  5.  
  6.     File name:  events$Prototype.name$.h  
  7.     Function:  This module contains the extra event handler routines
  8.      These routines allow us to override events in the main loop,
  9.      and to handle unique events.
  10.     History: $Date$ Original by $Author$
  11.  
  12.    */
  13.  
  14. /* ======================================================= */
  15. /* ======================================================= */
  16.  
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20.  
  21. /* Handle the OS event */
  22. void DoOSEvent(EventRecord *myEvent);
  23.  
  24. /* Handle special key combinations */
  25. Boolean HandleKey(EventRecord *myevent);
  26.  
  27. /* Special disk inserted handling */
  28. Boolean HandleDisk(EventRecord *myevent);
  29.  
  30. $$if HasZoomWindows
  31. /* Handle our special Zooms */
  32. void U_DoZoom(Rect *OldRect, WindowPtr whichWindow);
  33.  
  34. $$endif
  35. $$if HasResizableWindows
  36. /* Handle our special Grows */
  37. void U_DoGrow(Rect *OldRect, WindowPtr whichWindow);
  38.  
  39. $$endif
  40. /* Handle our special Moves */
  41. void U_Moved(Rect *OldRect, WindowPtr whichWindow);
  42.  
  43. $$if HasGoAwayBoxes
  44. /* Handle our special go aways */
  45. void U_GoAway(WindowPtr whichWindow);
  46.  
  47. $$endif
  48. /* Handle our special hits in our windows */
  49. void U_InContent(EventRecord *myEvent, WindowPtr whichWindow);
  50.  
  51. /* Handle our special updates */
  52. void U_Update(WindowPtr whichWindow);
  53.  
  54. /* Handle our special activates */
  55. void U_Activate(WindowPtr whichWindow,Boolean Do_An_Activate);
  56.  
  57. /* Handle our special activates */
  58. void U_EnableMenus(void);
  59.  
  60. /* Let us into the main loop */
  61. void ApplLoop$Prototype.name$(void);
  62.  
  63. /* Filter events from the main loop */
  64. void ApplEvent$Prototype.name$(Boolean *DoIt, EventRecord *myEvent);
  65.  
  66. /* Handle our special user events */
  67. void Handle_UserEvent(UserEventRec *TheUserEvent);
  68.  
  69. #ifdef __cplusplus
  70. }
  71. #endif
  72.  
  73. /* ======================================================= */
  74. /* ======================================================= */
  75. $$CloseFile
  76. $$Message User Events, u:events$Prototype.name$.c
  77. $$File u:events$Prototype.name$.c
  78. /*  $CopyRight$ */
  79. /*  events$Prototype.name$                                    Additional event handler routines
  80.  
  81.     File name:  events$Prototype.name$.c  
  82.     Function:  This module contains the extra event handler routines
  83.      These routines allow us to override events in the main loop,
  84.      and to handle unique events.
  85.     History: $Date$ Original by $Author$
  86.  
  87.    */
  88.  
  89. #include "mmCommon$Prototype.name$.h"    /* Common */
  90. #include "Common$Prototype.name$.h"        /* Common */
  91.  
  92. #include "events$Prototype.name$.h"        /* This file */
  93.  
  94. #pragma segment MainHooks
  95.  
  96. /* ======================================================= */
  97.  
  98. /* Routine: AE_OpenThisFile */
  99. /* Purpose: Called with files to be opened. Called both at program */
  100. /* startup and during running. */
  101.  
  102. void AE_OpenThisFile(FSSpec *theFSSpec,short WhichFile,short TotalToOpen)
  103. {
  104.  
  105. }
  106.  
  107. /* ======================================================= */
  108.  
  109. /* Routine: AE_PrintThisFile */
  110. /* Purpose: Called with files to be printed. Called both at program */
  111. /* startup and during running. */
  112.  
  113. void AE_PrintThisFile(FSSpec *theFSSpec,short WhichFile,short TotalToOpen)
  114. {
  115.  
  116. }
  117.  
  118. /* ======================================================= */
  119.  
  120. /* Routine: DoOSEvent */
  121. /* Purpose: Handle DoOSEvents */
  122.  
  123. void DoOSEvent(EventRecord *myEvent)
  124. {
  125.  
  126. if (((myEvent->message & osEvtMessageMask) >> 24) == suspendResumeMessage)/*  See which  */
  127.     {
  128.     if ((myEvent->message & resumeFlag) == 0)    /* Suspend */
  129.         InTheForeground = FALSE;
  130.     else
  131.         InTheForeground = TRUE;
  132.     }
  133. }
  134.  
  135. /* ======================================================= */
  136.  
  137. /* Routine: HandleKey */
  138. /* Purpose: Allow us to filter key strokes and special key combinations */
  139. /* Return TRUE if we let the main loop handle the key stroke */
  140.  
  141. Boolean HandleKey(EventRecord *myevent)
  142. {
  143. short        charCode;                            /* Key code */
  144. char        ch;                                    /* Key pressed in Ascii */
  145. Boolean        CmdKeyPressed;                        /* Command key pressed */
  146. Boolean        OptionKeyPressed;                    /* Option key pressed */
  147. Boolean        ShiftKeyPressed;                    /* Shift key pressed */
  148. Boolean        theHandleKey;                        /* value to return */
  149.  
  150.  
  151. theHandleKey = TRUE;                            /* Let the main loop handle it */
  152.  
  153. charCode = myevent->message & charCodeMask;        /* Get the character */
  154. ch = (char)charCode;                            /* Change it to ASCII */
  155.  
  156. CmdKeyPressed = ((myevent->modifiers & cmdKey) != 0);        /* See if Command key is down */
  157. OptionKeyPressed = ((myevent->modifiers & optionKey) != 0);    /* See if Option key is down */
  158. ShiftKeyPressed = ((myevent->modifiers & shiftKey) != 0);    /* See if Shift key is down */
  159.  
  160. /* Add your code here */
  161.  
  162. return(theHandleKey);                            /* Return if we let main routine handle it */
  163. }
  164.  
  165. /* ======================================================= */
  166.  
  167. /* Routine: HandleDisk */
  168. /* Purpose: Allow us to handle disk inserted events specially */
  169. /* Return TRUE if we let the main loop handle the key stroke */
  170.  
  171. Boolean HandleDisk(EventRecord *myevent)
  172. {
  173. Boolean        theHandleDisk;                        /* value to return */
  174.  
  175.  
  176. theHandleDisk = TRUE;                            /* Let the main loop handle it */
  177. return(theHandleDisk);                            /* Return if we let main routine handle it */
  178. }
  179.  
  180. $$if HasZoomWindows
  181. /* ======================================================= */
  182.  
  183. /* Routine: U_DoZoom */
  184. /* Purpose: Allow us in to handle it */
  185.  
  186. void U_DoZoom(Rect *OldRect, WindowPtr whichWindow)
  187. {
  188. }
  189.  
  190. $$endif
  191. $$if HasResizableWindows
  192. /* ======================================================= */
  193.  
  194. /* Routine: U_DoGrow */
  195. /* Purpose: Allow us in to handle it */
  196.  
  197. void U_DoGrow(Rect *OldRect, WindowPtr whichWindow)
  198. {
  199. }
  200.  
  201. $$endif
  202. /* ======================================================= */
  203.  
  204. /* Routine: U_Moved */
  205. /* Purpose: Allow us in to handle it */
  206.  
  207. void U_Moved(Rect *OldRect, WindowPtr whichWindow)
  208. {
  209. }
  210.  
  211. $$if HasGoAwayBoxes
  212. /* ======================================================= */
  213.  
  214. /* Routine: U_GoAway */
  215. /* Purpose: Allow us in to handle it */
  216.  
  217. void U_GoAway( WindowPtr whichWindow)
  218. {
  219. }
  220.  
  221. $$endif
  222. /* ======================================================= */
  223.  
  224. /* Routine: U_InContent */
  225. /* Purpose: Allow us in to handle it */
  226.  
  227. void U_InContent(EventRecord *myEvent, WindowPtr whichWindow)
  228. {
  229. }
  230.  
  231. /* ======================================================= */
  232.  
  233. /* Routine: U_Update */
  234. /* Purpose: Allow us in to handle it */
  235.  
  236. void U_Update(WindowPtr whichWindow)
  237. {
  238. }
  239.  
  240. /* ======================================================= */
  241.  
  242. /* Routine: U_Activate */
  243. /* Purpose: Allow us in to handle it */
  244.  
  245. void U_Activate(WindowPtr whichWindow,Boolean Do_An_Activate)
  246. {
  247. }
  248.  
  249. /* ======================================================= */
  250.  
  251. /* Routine: U_EnableMenus */
  252. /* Purpose: Allow us in to handle it */
  253.  
  254. void U_EnableMenus(void)
  255. {
  256. }
  257.  
  258. /* ======================================================= */
  259.  
  260. /* Routine: ApplLoop$Prototype.name$ */
  261. /* Purpose: At the top of the main loop, called each time thru the main */
  262. /* loop.  This is very often if WNE was false. */
  263.  
  264. void ApplLoop$Prototype.name$(void)
  265. {
  266. }
  267.  
  268. /* ======================================================= */
  269.  
  270. /* Routine: ApplEvent$Prototype.name$ */
  271. /* Purpose: Allow us to filter all events before the main loop handles them */
  272. /* Set  DoIt  to TRUE to let the main loop handle the event. */
  273.  
  274. void ApplEvent$Prototype.name$(Boolean *DoIt, EventRecord *myEvent)
  275. {
  276.  
  277. *DoIt = TRUE;                                        /* Let the main loop handle it */
  278.  
  279. if (WNE)                                            /* Check for mouse in cursor area available */
  280.     {
  281.     /* Check cursor region for possible cursor shape change, cursorRgn */
  282.     }
  283.  
  284. if (myEvent->what == 0)                             /* Handle a NULL event*/
  285.     *DoIt = FALSE;                                    /* Tell the main loop to skip it*/
  286. }
  287.  
  288. /* ======================================================= */
  289.  
  290. /* Routine: Handle_UserEvent */
  291. /* Purpose: Handle our special user events */
  292.  
  293. void Handle_UserEvent(UserEventRec *TheUserEvent)
  294. {
  295. }
  296.  
  297. /* ======================================================= */
  298. /* ======================================================= */
  299. $$CloseFile
  300.  
  301.  
  302.